<template>
  <div id="acceptanceList">
    <div class="container">
        <DataTable rowKey="orderId" :border="false" :tableData="Data" :showConfig='false' :tableColumn="tableColumn" :pageConfig="pageConfig"></DataTable>
    </div>
  </div>
</template>
<script lang='ts'>
import { Component, Watch, Vue } from 'vue-property-decorator';

@Component
export default class purchase extends Vue {
    searchForm: any = {
        projectId: undefined,
        name: '',
        orderStatus: undefined
    }
    projectList:any[] = []
    Data: any[] = [];
    tableColumn: any = {
      checkSn: {
          label: '序号',
          width: 30
      },
      orderSn: {
        label: '验收编号',
        width: 120
      },
      projectName: {
          label: '验收员',
          width: 120
      },
      supplierName: {
          label: '复验员',
          width: 120
      },
      cdeptName: {
          label: '审核员',
          width: 120
      },
      orderStatus: {
          label: '审核时间',
          width: 100
      },
      action: {
          label: '操作',
          width: 120,
          template: [
          {
            tag: 'router-link',
            text: '详情',
            query: {
              _alias: 'detail',
              orderId: ''
            },
            show: true
            // path: '/acceptance/purchase/purchaseDetails'
          }
        ]
      }
    };
    pageConfig: any = {
        current: 1,
        total: 10,
        pageSize: 10,
        onChange: this.changePage
    };

  get getSearchForm () {
    return {
      ...this.searchForm
    }
  }

  init () {
    // this.getList();
  }
  changePage (val: number) {
    console.log(val, '===')
    this.pageConfig.current = val;
    this.getList();
  }
  getList () {
    let data = {
      ...this.getSearchForm,
      page: this.pageConfig.current,
      size: this.pageConfig.pageSize
    };
    this.$api.checkOrderCheckOrderListFetch(data).then((res: any) => {
      res.data.records.map((item:any, index:any) => {
        item.checkSn = index + 1
      })
      this.Data = res.data.records;
      this.pageConfig.total = res.data.total;
      if (!this.Data.length && this.pageConfig.current > 1) {
        --this.pageConfig.current;
        this.getList();
      }
    });
  }
}
</script>
<style lang='scss' scoped></style>
